Parsability of code snippets

ABSTRACT

Operations may include obtaining a code artifact in which the code artifact is a code snippet is of a software language of interest. The operations may also include identifying fault locations of the code snippet that each correspond to a parsing error. In addition, the operations may include implementing repairs for each identified fault location in which, for each fault location, a respective repair is implemented for its corresponding parsing error such that the code snippet is modified into a parsable code snippet.

FIELD

The embodiments discussed in the present disclosure are related toimproving the parsability of code snippets.

BACKGROUND

Software developer forums present a rich, hybrid knowledge base ofnatural language descriptions and code snippets related to developingsoftware programs such as fixing errors (also referred to as bugs orviolations) in the software programs. Software development tools may beconfigured to perform machine analysis operations to extract and processcode snippets from the forums for use in the development process.However, a vast majority of code snippets on such developer forums tendto be syntactically incongruent with their corresponding softwarelanguage, which may make them unparsable and unsuitable for machineanalysis. Further, the snippets may also contain natural languagefragments, which may not be recognized by automated code analysistechniques for parsing. These problems restrict the use of code snippetson developer forums to only a small set of machine analyzable snippets.

The subject matter claimed in the present disclosure is not limited toembodiments that solve any disadvantages or that operate only inenvironments such as those described above. Rather, this background isonly provided to illustrate one example technology area where someembodiments described in the present disclosure may be practiced.

SUMMARY

Operations may include obtaining a code artifact in which the codeartifact is a code snippet is of a software language of interest. Theoperations may also include identifying fault locations of the codesnippet that each correspond to a parsing error. In addition, theoperations may include implementing repairs for each identified faultlocation in which, for each fault location, a respective repair isimplemented for its corresponding parsing error such that the codesnippet is modified into a parsable code snippet.

The objects and advantages of the embodiments will be realized andachieved at least by the elements, features, and combinationsparticularly pointed out in the claims.

Both the foregoing general description and the following detaileddescription are given as examples and are explanatory and are notrestrictive of the invention, as claimed.

BRIEF DESCRIPTION OF THE DRAWINGS

Example embodiments will be described and explained with additionalspecificity and detail through the use of the accompanying drawings inwhich:

FIG. 1A is a diagram representing an example environment related tomodifying unparsable code snippets such that they are parsable;

FIG. 1B illustrates various code examples;

FIG. 2 illustrates a block diagram of an example computing system thatmay be used to generate a parsable code snippet from an unparsable codesnippet;

FIG. 3 is a flowchart of an example method of generating a parsable codesnippet from an unparsable code snippet;

FIG. 4 is a flowchart of an example method of performing an eliminationbased inference with respect to whether a particular code snippetcorresponds to a particular software language of interest;

FIG. 5 is a flowchart of an example method of identifying undefinedtokens in a particular code snippet;

FIG. 6A is a flowchart of an example method of identifying and repairingparsing errors in a particular code snippet;

FIG. 6B illustrates an example repair template that may be used torepair parsing errors; and

FIGS. 7A-7F illustrate an example of how methods 300, 400, 500, and 600may be applied to an example code snippet.

DESCRIPTION OF EMBODIMENTS

Some embodiments described in the present disclosure relate to methodsand systems of making unparsable code snippets parsable such that thecode snippets may be analyzed by software development tools that performautomated code analysis. For instance, code artifacts may include textthat may include portions of code of a software language of interest(referred to as “code snippets”). However, the code artifacts may besyntactically incongruent with respect to the language of interest suchthat the code artifacts may be unparsable by the software developmenttools with respect to the language of interest. For example, the codesnippets of the code artifacts may be missing syntactic characters(e.g., brackets, semi-colons, etc.), may have extraneous syntacticcharacters, and/or may include undefined tokens (e.g., an ellipse inplace of actual code). In these or other embodiments, the code artifactsmay have invalid text fragments with respect to the language of interestthat are not code snippets of the language of interest. (e.g., naturallanguage text, code of another software language, reports, etc.). In thepresent disclosure reference to a code artifact may refer to any textthat may be related to software code. As such, in some instances a “codeartifact” may be or may include a code snippet that may be source codeor text written in source code format. Additionally or alternativelytext that is not necessarily source code or written in source codeformat, such as reports or descriptions related to statements orexpressions of source code, may also be referred to as a “code artifact”in the present disclosure.

According to one or more embodiments of the present disclosure, amodification module (e.g., of a software development tool) may beconfigured to analyze a code artifact to identify portions of the codeartifact that may be syntactically incongruent with respect to thelanguage of interest. For example, the modification module may beconfigured to identify and distinguish code snippets of code artifactsfrom other text related to software code. In these or other embodiments,the modification module may be configured to identify and correctsyntactic incongruencies of the identified code snippets such that thatthe code snippets may be parsable.

The parsable code snippets may then be used in the development ofsoftware programs written in the language of interest. For example,repair strategies for a software program in development may beidentified from the parsable code snippets. For instance, a particularparsable code snippet may include a repair for a particular bug includedin the software program in development. The particular parsable codesnippet may be parsed by a software development tool and may beidentified, from the parsing, as a repair for the particular bug. Theabove is merely one example of how the parsable code snippet may be usedby a software development tool in debugging (e.g., identifying errors,repairing errors, etc.) of the software program in development.

As such, according to one or more embodiments of the present disclosure,the technological field of software development may be improved byconfiguring a computer system in a manner in which the computing systemis able to modify unparsable code snippets such that they are parsablewith respect to a language of interest in which the parsable codesnippet may be used to identify bugs and/or repairs in softwareprograms.

Embodiments of the present disclosure are explained with reference tothe accompanying drawings.

FIG. 1A is a diagram representing an example environment 100 related toidentifying and modifying unparsable code snippets such that they areparsable. The environment 100 may include a modification module 102configured to analyze an code artifact 104 (“artifact 104”). In these orother embodiments, the artifact 104 may include an unparsable codesnippet (“unparsable snippet”) that may be identified by the analysis ofthe artifact 104. Additionally or alternatively, the modification module102 may be configured to modify the unparsable snippet into a parsablecode snippet 106 (“parsable snippet 106”).

The artifact 104 may include text that may include portions of code of asoftware language of interest. For example, the artifact 104 may includecode snippets that are portions of source code written in any applicableprogramming language such as, for example, C++, C, assembly, C#, Java,BASIC, JavaScript, Python, Perl, HTML (HyperText Markup Language), XML(Extensible Markup Language), and SQL (Structured Query Language), amongothers. In these or other embodiments, the artifact 104 may include textthat is invalid with respect to the software language of interest. Forexample, the artifact 104 may include natural language text, code ofanother software language, reports regarding tests, etc.

In some embodiments, the artifact 104 may be syntactically incongruentwith respect to the language of interest such that the artifact 104 maybe unparsable by a software development tool with respect to thelanguage of interest. For example, the artifact 104 may be an unparsablesnippet that may be missing syntactic characters (e.g., brackets,semi-colons, etc.), may have extraneous syntactic characters, and/or mayinclude tokens that are not defined for the language of interest(“undefined tokens” e.g., an ellipse in place of actual code).Additionally or alternatively, the artifact 104 may have invalid textfragments with respect to the language of interest (e.g., naturallanguage text, code of another software language, reports regardingtests, etc.) such that the artifact 104 is not a code snippet of thelanguage of interest.

By way of example and illustration, FIG. 1B illustrates an example 110of Java code that is syntactically complete such that example 110 is aparsable Java code snippet. FIG. 1B also illustrates an example 112 ofJava code that is missing syntactic characters 120 and 122 of example110 such that example 112 is syntactically incongruent with respect toJava grammar and is thus an unparsable Java code snippet. As anotherexample, FIG. 1B illustrates an example 114 of Java code that has anadditional syntactic character 124 that renders example 114syntactically incongruent with respect to Java and thus unparsable withrespect to Java. As another example, FIG. 1B illustrates an example 116of Java code in which expression 126 of example 110 has been replacedwith an ellipse 128 (“ . . . ”) such that example 116 is syntacticallyincongruent with respect to Java and thus unparsable with respect toJava. As another example, FIG. 1B illustrates an example 118 of a codeartifact that is a Java error statement and not actual Java code suchthat example 118 is syntactically incongruent with respect to Java andthus unparsable with respect to Java.

Returning to FIG. 1A, the modification module 102 may include code androutines configured to enable a computing device to perform one or moreoperations with respect to the artifact 104 to generate the parsablesnippet 106. Additionally or alternatively, the modification module 102may be implemented using hardware including a processor, amicroprocessor (e.g., to perform or control performance of one or moreoperations), a field-programmable gate array (FPGA), or anapplication-specific integrated circuit (ASIC). In some other instances,the modification module 102 may be implemented using a combination ofhardware and software. In the present disclosure, operations describedas being performed by the modification module 102 may include operationsthat the modification module 102 may direct a corresponding system(e.g., a computing system that includes the modification module 102) toperform.

The modification module 102 may be configured to obtain the artifact104. In some embodiments, the modification module 102 may be configuredto obtain the artifact 104 from a repository of code artifacts. Forexample, the artifact 104 may be included on a software developer forum,which may operate as an informal repository of code artifacts. Forinstance, members of the forum may post code artifacts (e.g., codesnippets, error reports, etc.) as part of discussions regarding softwaredevelopment (e.g., debugging discussions). The code artifacts may oftenbe written as modified source code that may be syntactically incongruentwith a language of interest of a particular discussion or may not be ofsource code of the particular language of interest. As such, in someembodiments, the modification module 102 may be configured to obtain theunparsable snippet 104 from a software development forum. Additionallyor alternatively, the discussions of one or more software developmentforums may be stored in a repository and the modification module 102 maybe configured to obtain the artifact 104 from the repository. In theseor other embodiments, the artifact 104 may be obtained from any otherapplicable software documentation source such as API (ApplicationProgram Interface) documentation, tutorials, and/or help pages ofsoftware development artifacts (e.g., tools, languages, frameworks,etc.).

The modification module 102 may be configured to analyze the artifact104 to identify portions of the artifact 104 that may be syntacticallyincongruent with respect to the language of interest. In these or otherembodiments, the modification module 102 may be configured to modify theartifact 104 to correct for the syntactic incongruence to generate theparsable snippet 106, which may be parsable with respect to the languageof interest. The parsable snippet 106 may be used in the development ofsoftware programs in an applicable manner. For example, the parsablesnippet 106 may be used to identify and/or repair errors in othersoftware programs that are written in the language of interest.

Additionally or alternatively, the modification module 102 may identifythe artifact 104 as corresponding to a software language that isdifferent from the language of interest. In these or other embodiments,rather than generating the parsable snippet 106, the modification module102 may be configured to annotate the artifact 104 to indicate to whichsoftware language the artifact 104 corresponds. In some instances inwhich the artifact 104 corresponds to another software languagedifferent from the software language of interest, the artifact 104 maybe unparsable with respect to the software language of interest, but notwith respect to the other software language. Additionally oralternatively, the artifact 104 may be of a certain type of report andthe modification module 102 may be configured to annotate the artifact104 to indicate the report type. In some embodiments, the modificationmodule 102 may be configured to analyze and modify the artifact 104according to one or more operations described below with respect toFIGS. 3-6.

Modifications, additions, or omissions may be made to FIG. 1 withoutdeparting from the scope of the present disclosure. For example, theenvironment 100 may include more or fewer elements than thoseillustrated and described in the present disclosure.

FIG. 2 illustrates a block diagram of an example computing system 202that may be used to generate a parsable code snippet from an unparsablecode snippet, according to at least one embodiment of the presentdisclosure. The computing system 202 may be configured to implement ordirect one or more operations associated with a modification module(e.g., the modification module 102 of FIG. 1 in some embodiments. Thecomputing system 202 may include a processor 250, a memory 252, and adata storage 254. The processor 250, the memory 252, and the datastorage 254 may be communicatively coupled.

In general, the processor 250 may include any suitable special-purposeor general-purpose computer, computing entity, or processing deviceincluding various computer hardware or software modules and may beconfigured to execute instructions stored on any applicablecomputer-readable storage media. For example, the processor 250 mayinclude a microprocessor, a microcontroller, a digital signal processor(DSP), an application-specific integrated circuit (ASIC), aField-Programmable Gate Array (FPGA), or any other digital or analogcircuitry configured to interpret and/or to execute program instructionsand/or to process data. Although illustrated as a single processor inFIG. 2, the processor 250 may include any number of processorsconfigured to, individually or collectively, perform or directperformance of any number of operations described in the presentdisclosure. Additionally, one or more of the processors may be presenton one or more different electronic devices, such as different servers.

In some embodiments, the processor 250 may be configured to interpretand/or execute program instructions and/or process data stored in thememory 252, the data storage 254, or the memory 252 and the data storage254. In some embodiments, the processor 250 may fetch programinstructions from the data storage 254 and load the program instructionsin the memory 252. After the program instructions are loaded into memory252, the processor 250 may execute the program instructions.

For example, in some embodiments, the modification module may beincluded in the data storage 254 as program instructions. The processor250 may fetch the program instructions of the modification module fromthe data storage 254 and may load the program instructions of themodification module in the memory 252. After the program instructions ofthe modification module are loaded into memory 252, the processor 250may execute the program instructions such that the computing system mayimplement the operations associated with the corresponding module asdirected by the instructions.

The memory 252 and the data storage 254 may include computer-readablestorage media for carrying or having computer-executable instructions ordata structures stored thereon. Such computer-readable storage media mayinclude any available media that may be accessed by a general-purpose orspecial-purpose computer, such as the processor 250. By way of example,and not limitation, such computer-readable storage media may includetangible or non-transitory computer-readable storage media includingRandom Access Memory (RAM), Read-Only Memory (ROM), ElectricallyErasable Programmable Read-Only Memory (EEPROM), Compact Disc Read-OnlyMemory (CD-ROM) or other optical disk storage, magnetic disk storage orother magnetic storage devices, flash memory devices (e.g., solid statememory devices), or any other storage medium which may be used to carryor store particular program code in the form of computer-executableinstructions or data structures and which may be accessed by ageneral-purpose or special-purpose computer. Combinations of the abovemay also be included within the scope of computer-readable storagemedia. Computer-executable instructions may include, for example,instructions and data configured to cause the processor 250 to perform acertain operation or group of operations.

Modifications, additions, or omissions may be made to the computingsystem 202 without departing from the scope of the present disclosure.For example, in some embodiments, the computing system 202 may includeany number of other components that may not be explicitly illustrated ordescribed.

FIG. 3 is a flowchart of an example method 300 of generating a parsablecode snippet from a code artifact, according to at least one embodimentdescribed in the present disclosure. The method 300 may be performed byany suitable system, apparatus, or device with respect to code undertest. For example, the modification module 102 of FIG. 1A, or thecomputing system 202 of FIG. 2 (e.g., as directed by the modificationmodule) may perform one or more of the operations associated with themethod 300. Although illustrated with discrete blocks, the steps andoperations associated with one or more of the blocks of the method 300may be divided into additional blocks, combined into fewer blocks, oreliminated, depending on the particular implementation.

At block 302, a code artifact may be obtained. In some embodiments, thecode artifact may be unparsable with respect to a particular softwarelanguage. In these or other embodiments, the code artifact may be listedon a software development forum. Additionally or alternatively, the codeartifact may be obtained from the software development forum or someother repository of code artifacts.

At block 304, it may be determined whether the code artifact is of aparticular software language that may be of interest. In someembodiments, the determination may be made based on whether the codeartifact conforms to a grammar of the particular software language. Insome embodiments, the determination as to whether the code artifactconforms to the grammar may be based on an elimination based inference.For instance, it may be determined whether the code artifact isformatted according to another software language format, a report (e.g.,error report, runtime report, output report, stacktrace report, logreport, etc.) format, etc. In these or other embodiments, in response todetermining that the code snippet is not formatted according to anothersoftware language format, a report format, etc., it may be determinedthat the code snippet is of the particular software language. In someembodiments, the elimination based inference may be performed accordingto one or more operations described below with respect to FIG. 4.

In some embodiments, in response to determining that the code artifactis not of the particular software language, the code artifact may beannotated at block 306. In these or other embodiments, the annotationmay indicate to what the code artifact may relate. For example, theannotation may indicate a type of report or software language of thecode artifact.

Returning to block 304, in response to determining that the codeartifact is of the particular software language, it may be determinedthat the code artifact is a code snippet of the particular softwarelanguage and the method 300 may proceed to block 308. At block 308, oneor more undefined tokens may be identified in one or more lines of thecode snippet. In some embodiments, the identification of undefinedtokens may be based on a grammar that may be written to identify suchtokens. For example, the grammar may be written to include one or moreregular expressions that may be used to search the code snippet for theundefined tokens. In these or other embodiments, the identification ofundefined tokens may be performed by determining whether each line ofcode matches a generated statement or expression regular expression. Insome embodiments, the identification of the undefined tokens may beperformed according to one or more operations described below withrespect to FIG. 5.

At block 310, the identified undefined tokens may be replaced with aparsable code fragment. For example, an identified undefined token thatmay be replaced with a dummy statement or dummy expression of theparticular language of interest. In some embodiments, the dummy codefragment may be encoded with a reference to the undefined token, whichmay be used to identify the location of the undefined token as part ofrepairing the code snippet to make it parsable. In some embodiments, thereplacement of undefined tokens may be performed according to one ormore operations described below with respect to FIG. 5.

At block 312, fault locations of the code snippet that each correspondto a parsing error may be identified. In some embodiments, one or moreof the fault locations may be portions of the code snippet that failed agrammar rule of the particular language of interest such that thecorresponding fault locations may be syntactically incongruent (e.g.,have a syntax error) with the particular language of interest. In theseor other embodiments, one or more of the fault locations may be a lineof code that has an undefined token replaced, such as described withrespect to block 310.

In some embodiments, the identification of fault locations may includebuilding a parse tree of the code snippet in which the parse treerepresents syntactic relationships of elements of the code snippet. Inthese or other embodiments, the parse tree may include error nodes thatindicate portions of the code snippet that result in parsing errors. Theerror nodes may accordingly indicate the fault locations of the codesnippet such that the error nodes may be used to identify the faultlocations.

At block 314, a parsing repair may be implemented at each faultlocation. The parsing repairs may be modifications made to the faultlocations to correct the parsing error that corresponds to eachrespective fault location. The modifications may be such that the codesnippet may be parsable.

In some embodiments, the repairs may be identified based on an errortype of the parsing errors of the fault locations. For example, in someembodiments, one or more of the repairs may be based on whether thefault location corresponds to a dummy code fragment that replaces anundefined token or a failed grammar rule. In these or other embodiments,one or more of the repairs may be based on the type of dummy codefragment or the type of failed grammar rule. Additionally oralternatively, the repairs may be selected and identified from aprecompiled library of specialized repair templates. In these or otherembodiments, one or more of the repairs may be identified from therepair templates based on a parent node type of parent nodes of theerror nodes of the parse tree. In some embodiments, the identificationof the fault locations, the corresponding errors and error types, andidentification and implementation of the corresponding repairs may beperformed according to one or more operations described below withrespect to FIG. 6.

One skilled in the art will appreciate that, for this and otherprocesses, operations, and methods disclosed herein, the functionsand/or operations performed may be implemented in differing order.Furthermore, the outlined functions and operations are only provided asexamples, and some of the functions and operations may be optional,combined into fewer functions and operations, or expanded intoadditional functions and operations without detracting from the essenceof the disclosed embodiments. In some embodiments, the method 400 mayinclude additional blocks or fewer blocks.

FIG. 4 is a flowchart of an example method 400 of performing anelimination based inference with respect to whether a particular codeartifact corresponds to a particular software language of interest,according to at least one embodiment described in the presentdisclosure. The method 400 may be performed by any suitable system,apparatus, or device with respect to code under test. For example, themodification module 102 of FIG. 1A, or the computing system 202 of FIG.2 (e.g., as directed by the modification module) may perform one or moreof the operations associated with the method 400. Further, as indicatedabove, in some embodiments, one or more of the operations of the method400 may be performed as part of operations 304 and 306 of the method 300of FIG. 3. Although illustrated with discrete blocks, the steps andoperations associated with one or more of the blocks of the method 400may be divided into additional blocks, combined into fewer blocks, oreliminated, depending on the particular implementation.

The method 400 in general may be used with respect to code artifactsthat are selected from a discussion on a developer forum in which thediscussion is related to the particular software language of interest.As such, the method 400 may be used to determine whether the particularcode artifact is formatted according to another software language formator a report format, and in response to determining that the particularcode artifact is not formatted according to another software languageformat or a report format, it may be determined that the particular codeartifact includes code of the particular software language of interestand is thus a code snippet of the particular software language ofinterest. In the present example, the particular software language ofinterest may be Java and the other software languages and the reportsmay include a stacktrace report, XML, a log output report, a commandline output report, and SQL. The other software languages and reportsthat may be part of the inference may vary depending on the particularsoftware language of interest and may be determined based on a heuristicanalysis as to which other software languages and which reports may beincluded in discussions related to the particular software language ofinterest.

At block 402, the particular code artifact may be scanned. The scanningmay be used to identify characters (e.g., words, grammatical symbols,etc.) included in the particular code artifact as well as thearrangement of the characters with respect to each other.

At block 404, using the identified characters and arrangement, it may bedetermined whether the particular code artifact matches the format of astacktrace report. For example, it may be determined whether one or moreof the characters of the particular code snippet are those that areuniquely associated with a stacktrace report. In these or otherembodiments, it may be determined whether one or more arrangements ofthe characters with respect to each other are uniquely associated with astacktrace report. In some embodiments, the determinations may be madeby determining whether one or more of the characters and/or arrangementsmatch a regular expression (e.g., a specific sequence of characters)that uniquely corresponds to stacktrace reports.

In response to one or more characters and/or arrangements of charactersmatching the format of a stacktrace report, the method 400 may proceedfrom block 404 to block 414. At block 414 it may be determined that theparticular code artifact corresponds to a stacktrace report. The method400 may proceed from block 414 to block 426 where the particular codeartifact may be annotated as corresponding to a stacktrace report.

Returning to block 404, in response to no characters and/or arrangementsof characters matching the format of a stacktrace report, the method 400may proceed from block 404 to block 406. At block 406, using theidentified characters and arrangement, it may be determined whether theparticular code artifact matches the format of XML code. For example, itmay be determined whether one or more of the characters of theparticular code artifact are those that are uniquely associated with XMLcode. In these or other embodiments, it may be determined whether one ormore arrangements of the characters with respect to each other areuniquely associated with XML code. In some embodiments, thedeterminations may be made by determining whether one or more of thecharacters and/or arrangements match a regular expression that uniquelycorresponds to XML code.

In response to one or more characters and/or arrangements of charactersmatching the format of XML code, the method 400 may proceed from block406 to block 416. At block 416 it may be determined that the particularcode artifact corresponds to XML code. The method 400 may proceed fromblock 416 to block 426 where the particular code artifact may beannotated as corresponding to XML code.

Returning to block 406, in response to no characters and/or arrangementsof characters matching the format of XML code, the method 400 mayproceed from block 406 to block 408. At block 408, using the identifiedcharacters and arrangement, it may be determined whether the particularcode artifact matches the format of an output log. For example, it maybe determined whether one or more of the characters of the particularcode artifact are those that are uniquely associated with output logreports. In these or other embodiments, it may be determined whether oneor more arrangements of the characters with respect to each other areuniquely associated with output logs. In some embodiments, thedeterminations may be made by determining whether one or more of thecharacters and/or arrangements match a regular expression that uniquelycorresponds to output logs.

In response to one or more characters and/or arrangements of charactersmatching the format of output logs, the method 400 may proceed fromblock 408 to block 418. At block 418 it may be determined that theparticular code artifact corresponds to an output log report. The method400 may proceed from block 418 to block 426 where the particular codeartifact may be annotated as corresponding to an output log report.

Returning to block 408, in response to no characters and/or arrangementsof characters matching the format of an output log report, the method400 may proceed from block 408 to block 410. At block 410, using theidentified characters and arrangement, it may be determined whether theparticular code artifact matches the format of a command line output.For example, it may be determined whether one or more of the charactersof the particular code artifact are those that are uniquely associatedwith command line outputs. In these or other embodiments, it may bedetermined whether one or more arrangements of the characters withrespect to each other are uniquely associated with command line outputs.In some embodiments, the determinations may be made by determiningwhether one or more of the characters and/or arrangements match aregular expression that uniquely corresponds to command line outputs.

In response to one or more characters and/or arrangements of charactersmatching the format of command line outputs, the method 400 may proceedfrom block 410 to block 420. At block 420 it may be determined that theparticular code artifact corresponds to a command line output. Themethod 400 may proceed from block 420 to block 426 where the particularcode artifact may be annotated as corresponding to a command lineoutput.

Returning to block 410, in response to no characters and/or arrangementsof characters matching the format of a command line output, the method400 may proceed from block 410 to block 412. At block 412, using theidentified characters and arrangement, it may be determined whether theparticular code artifact matches the format of SQL code. For example, itmay be determined whether one or more of the characters of theparticular code artifact are those that are uniquely associated with SQLcode. In these or other embodiments, it may be determined whether one ormore arrangements of the characters with respect to each other areuniquely associated with SQL code. In some embodiments, thedeterminations may be made by determining whether one or more of thecharacters and/or arrangements match a regular expression that uniquelycorresponds to SQL code.

In response to one or more characters and/or arrangements of charactersmatching the format of SQL code, the method 400 may proceed from block412 to block 422. At block 422 it may be determined that the particularcode artifact corresponds to SQL code. The method 400 may proceed fromblock 422 to block 426 where the particular code artifact may beannotated as corresponding to SQL code.

Returning to block 412, in response to no characters and/or arrangementsof characters matching the format of SQL code, the method 400 mayproceed from block 412 to block 424. At block 424 it may be determinedthat the particular code artifact is a code snippet that corresponds tothe particular software language of interest (e.g., Java in thisparticular example). In some embodiments, this determination may be madebecause the other possible software languages and reports have beenruled out. In some embodiments, in response to the determination atblock 424, the method 300 of FIG. 3 may proceed from block 304 to block308.

One skilled in the art will appreciate that, for this and otherprocesses, operations, and methods disclosed herein, the functionsand/or operations performed may be implemented in differing order.Furthermore, the outlined functions and operations are only provided asexamples, and some of the functions and operations may be optional,combined into fewer functions and operations, or expanded intoadditional functions and operations without detracting from the essenceof the disclosed embodiments. In some embodiments, the method 400 mayinclude additional blocks or fewer blocks. For example, thedeterminations made with respect to specific languages and reports aremerely given as examples and the number, order, and/or types ofdeterminations in making the elimination based inference may vary.

FIG. 5 is a flowchart of an example method 500 of identifying undefinedtokens in a particular code snippet, according to at least oneembodiment described in the present disclosure. The method 500 may beperformed by any suitable system, apparatus, or device with respect tocode under test. For example, the modification module 102 of FIG. 1A, orthe computing system 202 of FIG. 2 (e.g., as directed by themodification module) may perform one or more of the operationsassociated with the method 500. Further, as indicated above, in someembodiments, one or more of the operations of the method 500 may beperformed as part of operations 308 and 310 of the method 300 of FIG. 3after it has been determined that the particular code artifact is theparticular code snippet that corresponds to a particular softwarelanguage of interest. Although illustrated with discrete blocks, thesteps and operations associated with one or more of the blocks of themethod 500 may be divided into additional blocks, combined into fewerblocks, or eliminated, depending on the particular implementation.

In general, the method 500 may be configured to identify undefinedtokens by determining whether each line of code of the particular codesnippet matches an undefined statement or undefined expression format asdescribed in further detail below. The term “undefined statement” asused in the present disclosure may refer to undefined characters of theparticular code snippet that are substitutes for standalone statementsin the particular code snippet. The term “undefined expression” as usedin the present disclosure may refer to characters of the particular codesnippet that are embedded in a statement as a substitute for expressionsof the statement.

At block 502, a particular line of code of the particular code snippetmay be selected and scanned. The scanning may be used to identifycharacters (e.g., words, grammatical symbols, etc.) included in theparticular line of code as well as the arrangement of the characterswith respect to each other.

At block 504, using the identified characters and arrangement, it may bedetermined whether the particular code snippet matches the format ofundefined statements of the particular software language of interest.For example, it may be determined whether one or more of the charactersof the particular code snippet are those that are associated withundefined statements of the particular software language of interest. Inthese or other embodiments, it may be determined whether one or morearrangements of the characters with respect to each other are uniquelyassociated with undefined statements of the particular software languageof interest. In some embodiments, the determinations may be made bydetermining whether one or more of the characters and/or arrangementsmatch a regular expression that uniquely corresponds to undefinedstatements of the particular software language of interest. For example,sequences of periods (“.”), asterisks (“*”), or backquotes (“ ”), areoften used in place of statements of Java code in which such charactersequences are undefined with respect to Java. As such, regularexpressions that correspond to such sequences as used in place ofstatements may be used to determine whether the particular line of codeincludes an undefined Java statement. For instance, it may be determinedwhether one or more of the following regular expressions corresponds tothe particular line of code “{circumflex over( )}*[\[\(<{]?([\⋅\*′])\1+[\]\)>}]?*$”,“{circumflex over( )}*([\⋅\*′])\1+”, and “([\⋅*\′])\1+*$”.

The regular expression “{circumflex over( )}*[\[\(<{]?([\⋅\*′])\1+[\]\)>}]?*$” checks whether a line onlycontains the consecutive sequence of dots (.), asterisks (*), orbackquotes (′). Moreover, this regular expression checks whether thesequence is enclosed in different kinds of brackets, such as parentheses( ), braces { }, square brackets [ ], and angular brackets < >.

The regular expression “{circumflex over ( )}*([\.\*′])\1+” checkswhether the consecutive sequence of dots (.), asterisks (*), orbackquotes (′) is at the start of a line followed by other validcharacters. The regular expression, “([\ω\*′])\1+*$”. checks whether theconsecutive sequence is at the end of the line with preceding validcharacters

In response to one or more characters and/or arrangements of charactersmatching the undefined statement format of the particular softwarelanguage of interest, it may be determined that the particular line ofcode includes an undefined token in place of a valid statement and themethod 500 may proceed from block 504 to block 508. At block 508, theundefined token may be replaced with a dummy statement. The dummystatement may include any suitable statement that may be syntacticallycorrect with respect to the particular code of interest and that mayencode a reference to the corresponding undefined token. For example,the undefined token may be replaced with a dummy variable declaration,method call, or variable initialization. For instance, for an undefinedtoken of “ . . . ” the dummy variable declaration statement may be asfollows: “Object UNREC_TOKENS_STATEMENT_46_46_46” in which the “46” is areference to the dots”.” of the undefined token because the ASCII codefor a dot “.” is “46.” Similarly, a dummy method call for the undefinedtoken “ . . . ” may be as follows: “UNREC_TOKENS_STATEMENT_46_46_46();”. Additionally, a dummy variable initialization for the undefinedtoken “ . . . ” may be as follows: “Strings=UNREC_TOKENS_STATEMENT_46_46_46;”.

Returning to block 504, in response to no characters and/or arrangementsof characters matching the undefined statement format, the method 500may proceed from block 504 to block 506. At block 506, using theidentified characters and arrangement, it may be determined whether theparticular code snippet matches the format of undefined expressions ofthe particular software language of interest. For example, it may bedetermined whether one or more of the characters of the particular codesnippet are those that are associated with undefined expressions of theparticular software language of interest. In these or other embodiments,it may be determined whether one or more arrangements of the characterswith respect to each other are uniquely associated with undefinedexpressions of the particular software language of interest. In someembodiments, the determinations may be made by determining whether oneor more of the characters and/or arrangements match a regular expressionthat uniquely corresponds to undefined expressions of the particularsoftware language of interest. For example, sequences of periods (“.”),asterisks (“*”), or backquotes (“ ”), are often used in place ofexpressions of Java code. As such, regular expressions that correspondto such sequences as used in place of Java expressions may be used todetermine whether the particular line of code includes an undefined Javaexpression. For instance, it may be determined whether the followingregular expressions corresponds to the particular line of code“([\⋅\*′])\1+”. The regular expression “([\⋅\*′])\1+” may check forsequences of periods (“.”), asterisks (“*”), or backquotes but withoutrestrictions related to the start or end of a line due to the regularexpression “([\⋅\*′])\1+” corresponding to undefined expressions insteadof undefined statements.

In response to one or more characters and/or arrangements of charactersmatching the undefined expression format, it may be determined that theparticular line of code includes an undefined token in place of a validexpression and the method 500 may proceed from block 506 to block 510.At block 510, the undefined token may be replaced with a dummyexpression. The dummy expression may include any suitable expressionthat may be syntactically correct with respect to the particular code ofinterest and that may encode a reference to the corresponding undefinedtoken, such as described above.

Returning to block 506, in response to no characters and/or arrangementsof characters matching the undefined expression format of the particularsoftware language of interest, the method 500 may proceed from block 506to block 512. At block 512 it may be determined that the particular lineof code does not include an undefined token. In some embodiments, thisdetermination may be made because the particular line of code likelydoes not include an undefined token if it is not of the statement orexpression format.

One skilled in the art will appreciate that, for this and otherprocesses, operations, and methods disclosed herein, the functionsand/or operations performed may be implemented in differing order.Furthermore, the outlined functions and operations are only provided asexamples, and some of the functions and operations may be optional,combined into fewer functions and operations, or expanded intoadditional functions and operations without detracting from the essenceof the disclosed embodiments. In some embodiments, the method 500 mayinclude additional blocks or fewer blocks. For example, in someembodiments, the operations of the method 500 may be repeated untilevery line of the particular code snippet has been analyzed forundefined tokens.

FIG. 6 is a flowchart of an example method 600 of identifying andrepairing parsing errors in a particular code snippet, according to atleast one embodiment described in the present disclosure. The method 600may be performed by any suitable system, apparatus, or device withrespect to code under test. For example, the modification module 102 ofFIG. 1A, or the computing system 202 of FIG. 2 (e.g., as directed by themodification module) may perform one or more of the operationsassociated with the method 600. Further, as indicated above, in someembodiments, one or more of the operations of the method 600 may beperformed as part of operations 312 and 314 of the method 300 of FIG. 3.Although illustrated with discrete blocks, the steps and operationsassociated with one or more of the blocks of the method 600 may bedivided into additional blocks, combined into fewer blocks, oreliminated, depending on the particular implementation.

At block 602, a parse tree of the particular code snippet may be built.The parse tree may include an ordered tree structure that may representthe syntactic structure of the particular code snippet with respect tothe grammar of the software language of the particular code snippet. Thesyntactic structure may represent syntactic relationships of theelements (e.g., characters, tokens, objects (e.g., classes, variables,methods, functions, etc.), etc.) included in the particular codesnippet.

In some embodiments, the parse tree may include nodes that correspond todifferent elements of the particular code snippet. The nodes may beorganized in a hierarchal manner that includes parent nodes and one ormore children nodes of the parent nodes in which the children nodescorrespond to sub-elements of the elements that correspond to the parentnodes. For example, a particular parent node may correspond to afunction that includes a particular variable and a corresponding childnode may correspond to the particular variable.

In these or other embodiments, one or more nodes of the parse tree maybe identified as error nodes. The error nodes may be nodes thatcorrespond to portions of the particular code snippet that aresyntactically incongruent (e.g., have a syntax error, undefined token,etc.) with the software language of the particular code snippet (alsoreferred to as fault locations of the particular code snippet) and thatmay be indicated as such in the parse tree. In the present disclosure,the building of the parse tree may identify as error nodes thoselocations of the code snippet that correspond to a dummy code fragmentand those that have one or more syntax errors. In these or otherembodiments, the references included in the dummy code fragments may beused to identify the corresponding nodes as error nodes.

At block 604, an error node (e) of the parse tree may be identified. Asindicated above, the error node may correspond to a particular faultlocation of the particular code snippet.

In some embodiments, a type of the error node may also be identified. Insome embodiments, the error nodes may be categorized as a first type(T1) of error node that corresponds to a dummy code fragment (e.g.,dummy statement or dummy expression) that may be inserted in theparticular code snippet such as described above with respect to FIG. 5.Additionally or alternatively, the error nodes may be categorized as asecond type (T2) of error node that corresponds to a portion of theparticular code snippet that failed one or more grammar rules of thesoftware language of the particular code snippet. Accordingly, in someembodiments, the error node may be identified as type T1 or type T2 atblock 604 depending on whether or not it includes a dummy code fragmentor fails one or more grammar rules.

In these or other embodiments, the error node type may include a type ofportion of the particular code snippet that corresponds to the errornode. For example, the portion may correspond to a “try” block, a“catch” block, an “else” block, a dummy statement, a dummy expression,etc. In some embodiments, the error node may also be identified ashaving one of these types in addition to being of type T1 or T2.

At block 606, the parent node (p) of e may be identified. In these orother embodiments, a type of the parent node p may also be identified.The type of the parent node may correspond to the type of element of theparticular code snippet to which the parent node p may correspond. Forexample, the different types of elements may be a variable declarationor assignment, an “if” block, a “while” block, an argument, a class, afunction, a method, a type declaration, an “or” block, a statement asdescribed above, an expression as described above, a code block, etc.Accordingly, in some embodiments, the parent node p may be identified ashaving a type that corresponds to the type of its corresponding element.In some embodiments the error node may not have a parent node such thatthe operations of block 606 may be omitted.

At block 608, a set of candidate fixes (F) may be identified. In someembodiments, the set of candidate fixes may be identified based on thetype of the error node. In these or other embodiments, the set ofcandidate fixes may also be identified based on the type of the parentnode. The set of candidate fixes may include one or more repairs thatmay be of a certain type that may be used to repair the parsing error atthe fault location that corresponds to the error node. In someembodiments, the set of candidate fixes may be obtained from a libraryof repair templates that has been compiled. The repair templates mayinclude specialized repairs for the different types of error nodes andtheir corresponding parent nodes.

For example, FIG. 6B illustrates an example repair template 620 that maybe used to repair parsing errors. FIG. 6B is not meant to be limiting asto the different repair templates that may be used and is based on somecommon parsing errors and potential repairs. However, the repairtemplate may be expanded, contracted, or otherwise modified.

In the particular example of FIG. 6B, the repair template 620 mayinclude a first operations path 622 (“first path 622”) and a secondoperations path 624 (“second path 624”). The first path 622 may relateto instances in which the error node is of type T (corresponds to adummy code fragment) and the second path 624 may relate to instances inwhich the error node is of type T2 (corresponds to a failed grammarrule).

In path 622 (e.g., instances in which the error node is of type T1), itmay be determined whether the dummy code fragment is a dummy statementor a dummy expression. In response to the dummy code fragment being adummy statement, repair operations 626 may be performed. In repairoperations 626, the set of candidate fixes that may be selected mayinclude replacing the dummy statement with commented content. Forexample, the original undefined token of the dummy statement may beinserted but in a commented manner such that it is syntactically valid.In some embodiments, the original undefined token may be encoded in thedummy statement and may be decoded.

In response to the dummy code fragment being a dummy expression, repairoperations 628 may be performed. In repair operations 628, the parentnode type may be used to select the set of candidate fixes.

For example, in response to the parent node type being a variabledeclaration or assignment, the set of candidate fixes may includedifferent variable initializers that may be used for the correspondingvariable. In these or other embodiments, the different variableinitializers may correspond to a certain type of the correspondingvariable. The type of the corresponding variable may be identified bytraversing the parse tree bottom up from the parent node in someembodiments. For example, this repair action may be used to synthesize avalid variable initialization in the declaration of that variable.Additionally, the grammar for variable declaration is:

-   -   type var_name=initialization_expression;

Of these, at the current fault location in the parse tree, the var_namemay be known and the objective may be to generateinitialization_expression. However, to generate that expressionaccurately the type of that variable (var_name) may need to be knownThis information may be present in the parse tree, but at some locationabove the current node. Hence, the up-traversal may be performed to findthat type node in the parse tree.

As another example, in response to the parent node type being an “if”statement or a “while” statement, the set of candidate fixes may includedifferent dummy conditions that may be applied to the “if” statement orthe “while” statement. As another example, in response to the parentnode type being an argument list, the set of candidate fixes may includedummy arguments.

In path 624 (e.g., instances in which the error node is of type T2(corresponds to a failed grammar rule)), the parent node type may alsobe used to select the set of candidate fixes. For example, in responseto the parent node being of a “class” type, the set of candidate fixesmay include the insertion or deletion of syntactic characters such as “{}”, “{”, or “}” characters. As another example, in response to theparent node type being a code block or a type declaration, the set ofcandidate fixes may include inserting an enclosing class or an enclosingmethod. As another example, in response to the parent node type being ablock “or” statement without a trailing substatement, the set ofcandidate fixes may be based on a type of the portion of the particularcode snippet that corresponds to the error node. For example, inresponse to the error node corresponding to a “try” block, the set ofcandidate fixes may include “catch” blocks of code that may be insertedat the corresponding fault location. As another example, in response tothe error node corresponding to a “catch” block, the set of candidatefixes may include “try” blocks of code that may be inserted at thecorresponding fault location. As another example, in response to theerror node corresponding to an “else” block, the set of candidate fixesmay include “if” blocks that may be inserted at the corresponding faultlocation. As another example, in response to the parent node type beinga statement or expression, the set of candidate fixes may includeinsertion of syntactic characters such as “;”, “{ };”, or“$var-e.content”, in which “e.content” refers to encoded content

Returning to FIG. 6A, at block 610, a candidate fix “f” may be selectedfrom the set of candidate fixes “F” that is identified at block 608. Atblock 612, the selected candidate fix may be applied to the faultlocation of the particular code snippet that corresponds to the errornode.

At block 614, a parser may be run with respect to the particular codesnippet. The running of the parser may indicate whether the parsingerror at the fault location that corresponds to the error node has beenrepaired. At block 616, it may be determined whether the parsing errorhas been repaired. In response to the parsing error not being repaired,the method 600 may return to block 610 from block 616 where anothercandidate fix may be selected from the set of candidate fixes.

In response to the error being repaired, the method 600 may return toblock 604 where another error node may be identified. In someembodiments, the method 600 may be performed until every fault locationhas been repaired. In these or other embodiments, the particular codesnippet may accordingly be modified into a parsable code snippet.Additionally or alternatively, the method 600 may be performed until acertain number of repair attempts have been performed.

One skilled in the art will appreciate that, for this and otherprocesses, operations, and methods disclosed herein, the functionsand/or operations performed may be implemented in differing order.Furthermore, the outlined functions and operations are only provided asexamples, and some of the functions and operations may be optional,combined into fewer functions and operations, or expanded intoadditional functions and operations without detracting from the essenceof the disclosed embodiments. In some embodiments, the method 600 mayinclude additional blocks or fewer blocks. Additionally, the types ofrepair operations that are described are examples and not an exhaustivelist of all the repair operations that may be performed.

FIGS. 7A-7F illustrate an example of how one or more operations of oneor more of the methods 300, 400, 500, and 600 may be applied to anexample code artifact 702 (“artifact 702”) of FIG. 7A, according to oneor more embodiments of the present disclosure. For instance, theartifact 702 may be a code snippet of Java code and may be obtained froma Java discussion board. The artifact 702 may include five parsingerrors that may make it unparsable. The parsing errors may include amissing enclosing class, two undefined tokens (“ . . . ”), a missingclosing bracket “}”, and a missing catch block that corresponds to the“try” block.

The artifact 702 may be determined as being a Java code snippet atoperation 304 of method 300. In these or other embodiments, the artifact702 may be determined as being a Java code snippet using the eliminationbased inference operations of method 400.

The undefined tokens (“ . . . ”) may be identified as corresponding toundefined statements based on the operations of block 504 of method 500.In these or other embodiments, using the operations at block 508 ofmethod 500, the undefined tokens (“ . . . ”) may each be replaced togenerate a first modified code snippet 704 (illustrated in FIG. 7A). Forexample, each of the undefined tokens (“ . . . ”) of the artifact 702may be replaced with the dummy statement “ObjectUNREC_TOKENS_STATEMENT_46_46_46” at fault locations 703 and 705 togenerate the first modified code snippet 704.

Turning to FIG. 7B, based on the operations of block 602 of method 600,a parse tree 706 may be generated with respect to the first modifiedcode snippet 704. FIG. 7B illustrates a first portion 708 of the parsetree 706 that may include an error node 710. The error node 710 maycorrespond to the missing enclosing class parsing error of the artifact702. Based on one or more operations of the method 600 and using repairoperations 712 of the repair template 620 of FIG. 6B, the missingenclosing class may be inserted at fault location 716 to generate asecond modified code snippet 714 from the first modified code snippet704.

Turning to FIG. 7C, FIG. 7C illustrates a second portion 718 of theparse tree 706 that may include an error node 720. The error node 720may correspond to a first inserted dummy statement that may correspondto a first one of the undefined tokens “ . . . ” of the artifact 702.Based on one or more operations of the method 600 and using repairoperations 722 of the repair template 620 of FIG. 6B, the first dummystatement at fault location 703 may be replaced with a commented versionof the first undefined token “ . . . ” to generate a third modified codesnippet 724 from the second modified code snippet 714.

Turning to FIG. 7D, FIG. 7D illustrates a third portion 726 of the parsetree 706 that may include an error node 728. The error node 728 maycorrespond to the missing catch block parsing error of the artifact 702.Based on one or more operations of the method 600 and using repairoperations 730 of the repair template 620 of FIG. 6B, the missing catchblock may be inserted at fault location 734 to generate a fourthmodified code snippet 732 from the third modified code snippet 724.

Turning to FIG. 7E, FIG. 7E illustrates a fourth portion 736 of theparse tree 706 that may include an error node 738. The error node 738may correspond to the second inserted dummy statement that maycorrespond to the second one of the undefined tokens “ . . . ” of theartifact 702. Based on one or more operations of the method 600 andusing repair operations 722 of the repair template 620 of FIG. 6B, thesecond dummy statement at fault location 705 may be replaced with acommented version of the second undefined token “ . . . ” to generate afifth modified code snippet 740 from the third modified code snippet732.

Turning to FIG. 7F, FIG. 7F illustrates a fifth portion 742 of the parsetree 706 that may include an error node 744. The error node 744 maycorrespond to the missing closing bracket “}” parsing error of theartifact 702. Based on one or more operations of the method 600 andusing repair operations 746 of the repair template 620 of FIG. 6B, themissing closing bracket “}” may be inserted at fault location 750 togenerate a sixth modified code snippet 748 from the fourth modified codesnippet 740.

The sixth modified code snippet 748 may have all the parsing errorscorrected. As such, the sixth modified codes snippet 748 may be aparsable code snippet generated from the unparsable code snippet of theartifact 702.

Modifications, additions, or omissions may be made to FIGS. 7A-7Fwithout departing from the scope of the present disclosure. For example,the order of making modifications may be different than from thatdescribed. Further, two or more of the repair operations may beperformed simultaneously. The above is just merely to aid inunderstanding as to how an unparsable code snippet may be made parsable.

As indicated above, the embodiments described in the present disclosuremay include the use of a special purpose or general purpose computer(e.g., the processor 250 of FIG. 2) including various computer hardwareor software modules, as discussed in greater detail below. Further, asindicated above, embodiments described in the present disclosure may beimplemented using computer-readable media (e.g., the memory 252 or datastorage 254 of FIG. 2) for carrying or having computer-executableinstructions or data structures stored thereon.

As used in the present disclosure, the terms “module” or “component” mayrefer to specific hardware implementations configured to perform theactions of the module or component and/or software objects or softwareroutines that may be stored on and/or executed by general purposehardware (e.g., computer-readable media, processing devices, etc.) ofthe computing system. In some embodiments, the different components,modules, engines, and services described in the present disclosure maybe implemented as objects or processes that execute on the computingsystem (e.g., as separate threads). While some of the systems andmethods described in the present disclosure are generally described asbeing implemented in software (stored on and/or executed by generalpurpose hardware), specific hardware implementations or a combination ofsoftware and specific hardware implementations are also possible andcontemplated. In this description, a “computing entity” may be anycomputing system as previously defined in the present disclosure, or anymodule or combination of modulates running on a computing system.

Terms used in the present disclosure and especially in the appendedclaims (e.g., bodies of the appended claims) are generally intended as“open” terms (e.g., the term “including” should be interpreted as“including, but not limited to,” the term “having” should be interpretedas “having at least,” the term “includes” should be interpreted as“includes, but is not limited to,” etc.).

Additionally, if a specific number of an introduced claim recitation isintended, such an intent will be explicitly recited in the claim, and inthe absence of such recitation no such intent is present. For example,as an aid to understanding, the following appended claims may containusage of the introductory phrases “at least one” and “one or more” tointroduce claim recitations. However, the use of such phrases should notbe construed to imply that the introduction of a claim recitation by theindefinite articles “a” or “an” limits any particular claim containingsuch introduced claim recitation to embodiments containing only one suchrecitation, even when the same claim includes the introductory phrases“one or more” or “at least one” and indefinite articles such as “a” or“an” (e.g., “a” and/or “an” should be interpreted to mean “at least one”or “one or more”); the same holds true for the use of definite articlesused to introduce claim recitations.

In addition, even if a specific number of an introduced claim recitationis explicitly recited, those skilled in the art will recognize that suchrecitation should be interpreted to mean at least the recited number(e.g., the bare recitation of “two recitations,” without othermodifiers, means at least two recitations, or two or more recitations).Furthermore, in those instances where a convention analogous to “atleast one of A, B, and C, etc.” or “one or more of A, B, and C, etc.” isused, in general such a construction is intended to include A alone, Balone, C alone, A and B together, A and C together, B and C together, orA, B, and C together, etc.

Further, any disjunctive word or phrase presenting two or morealternative terms, whether in the description, claims, or drawings,should be understood to contemplate the possibilities of including oneof the terms, either of the terms, or both terms. For example, thephrase “A or B” should be understood to include the possibilities of “A”or “B” or “A and B.” This interpretation of the phrase “A or B” is stillapplicable even though the term “A and/or B” may be used at times toinclude the possibilities of “A” or “B” or “A and B.”

All examples and conditional language recited in the present disclosureare intended for pedagogical objects to aid the reader in understandingthe present disclosure and the concepts contributed by the inventor tofurthering the art, and are to be construed as being without limitationto such specifically recited examples and conditions. Althoughembodiments of the present disclosure have been described in detail,various changes, substitutions, and alterations could be made heretowithout departing from the spirit and scope of the present disclosure.

What is claimed is:
 1. A method comprising: obtaining a code artifact inwhich the code artifact is a code snippet is of a software language ofinterest; identifying an undefined token in a particular line of code ofthe code snippet, the undefined token being undefined with respect tothe software language of interest; replacing the undefined token with adummy code fragment of the software language of interest; identifyingfault locations of the code snippet that each correspond to a parsingerror, one of the fault locations including the particular line of code;and implementing repairs for each identified fault location in which,for each fault location, a respective repair is implemented for itscorresponding parsing error such that the code snippet is modified intoa parsable code snippet.
 2. The method of claim 1, further comprisingdetermining that the code artifact is the code snippet of the softwarelanguage of interest based on determining that the code artifactconforms to a grammar of the software language of interest through anelimination based inference.
 3. The method of claim 1, whereinidentifying the undefined token is in response to the undefined tokenmatching a regular expression that corresponds to an undefined statementor an undefined expression of the software language of interest.
 4. Themethod of claim 1, wherein identifying the fault locations includes:building a parse tree of the code snippet that represents syntacticrelationships of elements of the code snippet; and identifying errornodes of the parse tree in which each error node indicates a respectivefault location.
 5. The method of claim 1, wherein implementing one ormore of the repairs includes identifying the one or more repairs basedon an error type of the parsing error of the fault locationscorresponding to the one or more repairs.
 6. The method of claim 5,wherein identifying the one or more repairs is further based on a parentnode type of parent nodes of error nodes of a parse tree in which theparse tree represents syntactic relationships of elements of the codesnippet and in which each error node indicates a respective faultlocation.
 7. The method of claim 1, wherein implementing one or more ofthe repairs includes identifying the one or more repairs from a repairtemplate of a precompiled library of specialized repairs.
 8. The methodof claim 1, wherein replacing the undefined token with the code fragmentincludes selecting a dummy statement of the language of interest as thecode fragment in response to determining that the particular line ofcode matches an undefined statement format.
 9. The method of claim 1,wherein replacing the undefined token with the code fragment includesselecting a dummy expression of the language of interest as the codefragment in response to determining that the particular line of codematches an undefined expression format.
 10. One or more non-transitorycomputer-readable media configured to store one or more instructionsthat, in response to being executed by at least one system, cause the atleast one system to perform operations, the operations comprising:obtaining a code artifact in which the code artifact is a code snippetis of a software language of interest; identifying an undefined token ina particular line of code of the code snippet, the undefined token beingundefined with respect to the software language of interest; replacingthe undefined token with a dummy code fragment of the software languageof interest; identifying fault locations of the code snippet that eachcorrespond to a parsing error, one of the fault locations including theparticular line of code; and implementing repairs for each identifiedfault location in which, for each fault location, a respective repair isimplemented for its corresponding parsing error such that the codesnippet is modified into a parsable code snippet.
 11. The one or morenon-transitory computer-readable media of claim 10, wherein theoperations further comprise determining that the code artifact is thecode snippet of the software language of interest based on determiningthat the code artifact conforms to a grammar of the software language ofinterest through an elimination based inference.
 12. The one or morenon-transitory computer-readable media of claim 10, wherein identifyingthe undefined token is in response to the undefined token matching aregular expression that corresponds to an undefined statement or anundefined expression of the software language of interest.
 13. The oneor more non-transitory computer-readable media of claim 10, whereinidentifying the fault locations includes: building a parse tree of thecode snippet that represents syntactic relationships of elements of thecode snippet; and identifying error nodes of the parse tree in whicheach error node indicates a respective fault location.
 14. The one ormore non-transitory computer-readable media of claim 10, whereinimplementing one or more of the repairs includes identifying the one ormore repairs based on an error type of the parsing error of the faultlocations corresponding to the one or more repairs.
 15. The one or morenon-transitory computer-readable media of claim 14, wherein identifyingthe one or more repairs is further based on a parent node type of parentnodes of error nodes of a parse tree in which the parse tree representssyntactic relationships of elements of the code snippet and in whicheach error node indicates a respective fault location.
 16. The one ormore non-transitory computer-readable media of claim 10, whereinreplacing the undefined token with the code fragment includes selectinga dummy statement of the language of interest as the code fragment inresponse to determining that the particular line of code matches anundefined statement format.
 17. The one or more non-transitorycomputer-readable media of claim 10, wherein replacing the undefinedtoken with the code fragment includes selecting a dummy expression ofthe language of interest as the code fragment in response to determiningthat the particular line of code matches an undefined expression format.18. A system comprising: one or more computer-readable storage mediaconfigured to store instructions; and one or more processorscommunicatively coupled to the one or more computer-readable storagemedia and configured to, in response to execution of the instructions,cause the system to perform operations, the operations comprising:obtaining a code artifact in which the code artifact is a code snippetis of a software language of interest; identifying fault locations ofthe code snippet that each correspond to a parsing error; andimplementing repairs for each identified fault location in which, foreach fault location, a respective repair is implemented for itscorresponding parsing error such that the code snippet is modified intoa parsable code snippet.
 19. The system of claim 18, wherein theoperations further comprise: identifying an undefined token in aparticular line of code of the code snippet, the undefined token beingundefined with respect to the software language of interest; andreplacing the undefined token with a dummy code fragment of the softwarelanguage of interest, wherein one of the fault locations includes theparticular line of code.
 20. The system of claim 18, wherein identifyingthe fault locations includes: building a parse tree of the code snippetthat represents syntactic relationships of elements of the code snippet;and identifying error nodes of the parse tree in which each error nodeindicates a respective fault location.